From c3176ed302471af5db9e2369d1bab12b200602ab Mon Sep 17 00:00:00 2001 From: =?utf8?q?Timm=20B=C3=A4der?= Date: Thu, 20 Jul 2017 12:33:57 +0200 Subject: [PATCH] overlay: Keep the main child at the bottom Since gtk_bin_add does a gtk_widget_set_parent call, we cannot use it in a GtkBin implementation that has multiple child widgets and cares about their order. --- gtk/gtkoverlay.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/gtk/gtkoverlay.c b/gtk/gtkoverlay.c index 71dfd2d8bd..3e1de96232 100644 --- a/gtk/gtkoverlay.c +++ b/gtk/gtkoverlay.c @@ -335,6 +335,19 @@ gtk_overlay_get_child_position (GtkOverlay *overlay, return TRUE; } +static void +gtk_overlay_add (GtkContainer *container, + GtkWidget *widget) +{ + + /* We only get into this path if we have no child + * (since GtkOverlay is a GtkBin) and the only child + * we can add through gtk_container_add is the main child, + * which we want to keep the lowest in the hierarchy. */ + gtk_widget_insert_after (widget, GTK_WIDGET (container), NULL); + _gtk_bin_set_child (GTK_BIN (container), widget); +} + static void gtk_overlay_remove (GtkContainer *container, GtkWidget *widget) @@ -596,6 +609,7 @@ gtk_overlay_class_init (GtkOverlayClass *klass) widget_class->size_allocate = gtk_overlay_size_allocate; + container_class->add = gtk_overlay_add; container_class->remove = gtk_overlay_remove; container_class->forall = gtk_overlay_forall; container_class->set_child_property = gtk_overlay_set_child_property; -- 2.30.2